//
//  XDLMInvestHistoryViewController.m
//  xindailianmeng
//
//  Created by xu on 17/3/18.
//  Copyright © 2017年 xindailianmeng.cn. All rights reserved.
//

#import "XDLMInvestHistoryViewController.h"
#import "InvestHeadCell.h"
#import "InvestInfoCell.h"

@interface XDLMInvestHistoryViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong)UITableView            *tableView;
@property (nonatomic, strong)NSArray                *dateArr;

@end

@implementation XDLMInvestHistoryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self buildLayout];
    
    // Do any additional setup after loading the view.
}

- (void)buildLayout{
    self.dateArr = [NSArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",nil];
    self.title = @"投资记录";

    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH - 64) style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.showsVerticalScrollIndicator = NO;
    _tableView.backgroundColor = [LCCommon getColor:@"eeeeee"];
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_tableView];
}



-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.dateArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return 44;
    }else{
        return 60;
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *bg = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 60)];
    bg.backgroundColor = [LCCommon getColor:@"eeeeee"];
    
    UIView *wtBg = [[UIView alloc]initWithFrame:CGRectMake(0, 10, kScreenW, 50)];
    wtBg.backgroundColor = [UIColor whiteColor];
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(15, 50/2 - 17/2, kScreenW - 30, 17)];
    title.font = [UIFont systemFontOfSize:17];
    title.text = [NSString stringWithFormat:@"%@",[self.dateArr objectAtIndex:section]];
    title.textColor = [LCCommon getColor:@"333333"];
    [wtBg addSubview:title];
    [bg addSubview:wtBg];
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 1/[UIScreen mainScreen].scale)];
    line.backgroundColor = [LCCommon getColor:@"cccccc"];
    [wtBg addSubview:line];
    
    
    UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(0, 50 - 1/[UIScreen mainScreen].scale, kScreenW, 1/[UIScreen mainScreen].scale)];
    line1.backgroundColor = [LCCommon getColor:@"cccccc"];
    [wtBg addSubview:line1];
    
    return bg;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 60;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        static NSString *SimpleTableIdentifier = @"InvestHeadCell";
        InvestHeadCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
        if (!cell) {
            cell = [[InvestHeadCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier];
        }
        //赋值
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor clearColor];
        return cell;
    }else{
        static NSString *SimpleTableIdentifier = @"InvestInfoCell";
        InvestInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
        if (!cell) {
            cell = [[InvestInfoCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier];
        }
        //赋值
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor clearColor];
        return cell;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
